﻿using System;
using System.Drawing;
using System.IO;
using System.Threading;
using FotoAlbum.Sort;

namespace FotoAlbum.Async
{
    public class LoaderEventArgs
    {
        /// <summary>
        /// Get the unique id assigned to this image.
        /// </summary>
        public int Id { get; protected set; }

        /// <summary>
        /// Get the path to the image.
        /// </summary>
        public string Path { get; protected set; }

        /// <summary>
        /// Get the name of the image.
        /// </summary>
        public string Name { get; protected set; }

        /// <summary>
        /// Get or set the image.
        /// </summary>
        public Image Image { get; set; }

        /// <summary>
        /// The file info that can be compared against others.
        /// </summary>
        public FICompare Info { get; protected set; }

        /// <summary>
        /// Creates new event arguments used by various classes.
        /// </summary>
        /// <param name="id">The unique id of the image.</param>
        /// <param name="fi">The file info of the image.</param>
        /// <param name="image">The actual image.</param>
        public LoaderEventArgs(int id, FileInfo fi, Image image)
        {
            this.Id = id;
            this.Path = fi.FullName;
            this.Name = fi.Name;
            this.Image = image;
            this.Info = new FICompare(fi);
        }

        /// <summary>
        /// Release the system resources used by the image.
        /// </summary>
        public void Dispose()
        {
            if (Image != null)
            {
                Image.Dispose();
                Image = null;
            }
        }
    }
}
